package com.platform.hjt.erp.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.platform.hjt.sys.model.SysCompanyInfo;
import com.platform.hjt.sys.model.SysUserInfo;
import com.platform.hjt.sys.model.json.SysCompanyInfoSerialize;
import com.platform.hjt.sys.model.json.SysUserInfoSerialize;

/**
 * ErpStorage entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "erp_storage")
public class ErpStorage implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -8360857265000093815L;
	private String erpStorageId;
	private SysCompanyInfo sysCompanyInfo;
	@NotNull(message="管理员不能为空")
	private SysUserInfo sysUserInfo;
	@NotBlank(message="仓库名称不能为空")
	@Length(max=100, message="名称长度不能超过100个字")
	private String storageName;
	@NotBlank(message="仓库编码不能为空")
	@Length(max=100, message="编码长度不能超过100个字")
	private String storageCode;
	@Length(max=500, message="仓库地址长度不能超过500个字")
	private String storageAddress;
	private Timestamp createTime;
	private Boolean isDel;
	private Integer sortIndex;
	private Set<ErpStorageFlow> erpStorageFlows = new HashSet<ErpStorageFlow>(0);

	// Constructors

	/** default constructor */
	public ErpStorage() {
	}

	/** minimal constructor */
	public ErpStorage(String erpStorageId) {
		this.erpStorageId = erpStorageId;
	}

	/** full constructor */
	public ErpStorage(String erpStorageId, SysCompanyInfo sysCompanyInfo,
			SysUserInfo sysUserInfo, String storageName, String storageCode,
			String storageAddress, Timestamp createTime, Boolean isDel,
			Integer sortIndex, Set<ErpStorageFlow> erpStorageFlows) {
		this.erpStorageId = erpStorageId;
		this.sysCompanyInfo = sysCompanyInfo;
		this.sysUserInfo = sysUserInfo;
		this.storageName = storageName;
		this.storageCode = storageCode;
		this.storageAddress = storageAddress;
		this.createTime = createTime;
		this.isDel = isDel;
		this.sortIndex = sortIndex;
		this.erpStorageFlows = erpStorageFlows;
	}

	// Property accessors
	@Id
	@GenericGenerator(name="systemUUID",strategy="uuid")
	@GeneratedValue(generator="systemUUID")
	@Column(name = "erp_storage_id", unique = true, nullable = false, length = 32)
	public String getErpStorageId() {
		return this.erpStorageId;
	}

	public void setErpStorageId(String erpStorageId) {
		this.erpStorageId = erpStorageId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sys_company_info_id")
	@JsonSerialize(using = SysCompanyInfoSerialize.class)
	public SysCompanyInfo getSysCompanyInfo() {
		return this.sysCompanyInfo;
	}

	public void setSysCompanyInfo(SysCompanyInfo sysCompanyInfo) {
		this.sysCompanyInfo = sysCompanyInfo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sys_user_info_id")
	@JsonSerialize(using = SysUserInfoSerialize.class)
	public SysUserInfo getSysUserInfo() {
		return this.sysUserInfo;
	}

	public void setSysUserInfo(SysUserInfo sysUserInfo) {
		this.sysUserInfo = sysUserInfo;
	}

	@Column(name = "storage_name", length = 200)
	public String getStorageName() {
		return this.storageName;
	}

	public void setStorageName(String storageName) {
		this.storageName = storageName;
	}

	@Column(name = "storage_code", length = 200)
	public String getStorageCode() {
		return this.storageCode;
	}

	public void setStorageCode(String storageCode) {
		this.storageCode = storageCode;
	}

	@Column(name = "storage_address", length = 500)
	public String getStorageAddress() {
		return this.storageAddress;
	}

	public void setStorageAddress(String storageAddress) {
		this.storageAddress = storageAddress;
	}

	@Column(name = "create_time", length = 19)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@Column(name = "is_del")
	public Boolean getIsDel() {
		return this.isDel;
	}

	public void setIsDel(Boolean isDel) {
		this.isDel = isDel;
	}

	@Column(name = "sort_index")
	public Integer getSortIndex() {
		return this.sortIndex;
	}

	public void setSortIndex(Integer sortIndex) {
		this.sortIndex = sortIndex;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "erpStorage")
	public Set<ErpStorageFlow> getErpStorageFlows() {
		return this.erpStorageFlows;
	}

	public void setErpStorageFlows(Set<ErpStorageFlow> erpStorageFlows) {
		this.erpStorageFlows = erpStorageFlows;
	}

}